<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>菜单管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap-4.6.2-dist/css/bootstrap.css">
</head>
<body style="padding: 20px">

<h2>菜单管理</h2>

<div>
    <a href="${pageContext.request.contextPath}/menu/add">
        <button type="button" class="btn btn-primary" style="margin: 10px 0 20px 0">添加菜单</button>
    </a>
</div>

<table width="90%" align="center" border="1" cellspacing="0" class="table table-striped">
    <tr class="thead-dark align-middle">
        <th>菜单名称</th>
        <th>菜单链接</th>
        <th>操作</th>
    </tr>

    <c:forEach items="${pageInfo.list}" var="menu">
        <tr class="align-middle">
            <td class="align-middle">${menu.name}</td>
            <td class="align-middle">${menu.url}</td>
            <td class="align-middle">
                <a href="${pageContext.request.contextPath}/menu/edit/${menu.id}">
                    <button class="btn btn-success">编辑</button>
                </a>
                <a href="${pageContext.request.contextPath}/menu/delete/${menu.id}" onclick="return confirm('确定删除？')">
                    <button class="btn btn-danger">删除</button>
                </a>
            </td>
        </tr>
    </c:forEach>
</table>
<!-- 分页导航 -->
<nav aria-label="Page navigation">
    <ul class="pagination justify-content-center">
        <li class="page-item">
            <a class="page-link" href="${pageContext.request.contextPath}/menu/list?pageNum=1" aria-label="首页">首页</a>
        </li>
        <li class="page-item">
            <a class="page-link" href="${pageContext.request.contextPath}/menu/list?pageNum=${pageInfo.prePage}" aria-label="上一页">上一页</a>
        </li>
        <li class="page-item">
            <a class="page-link" href="${pageContext.request.contextPath}/menu/list?pageNum=${pageInfo.nextPage}" aria-label="下一页">下一页</a>
        </li>
        <li class="page-item">
            <a class="page-link" href="${pageContext.request.contextPath}/menu/list?pageNum=${pageInfo.pages}" aria-label="尾页">尾页</a>
        </li>
    </ul>
</nav>
</body>
</html>
